package com.aabbc.rabbitmq.consumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

/**
 * OrderConsumer
 *
 * @author: <a href="mailto:chenfenghai@oristartech.com">chenfenghai</a>
 * @version: 1.0
 * @date: 2019-11-27 15:59
 */
@Slf4j
@Component
public class OrderConsumer2 {

    @RabbitHandler
    @RabbitListener(bindings = @QueueBinding(
            exchange = @Exchange(value = "IExchange",durable = "true",type = "topic"),
            value = @Queue(value = "topic_queue_1", durable = "true"),
            key = "*.orange.order"
    ))
    public void receiveSocket(@Payload String message, @Headers Map<String ,Object> headers,
                              Channel channel) throws IOException {
        log.info("2-----------接收到消息--------");
        log.info("2消息内容："+message);
    }
}
